﻿using UnityEngine;
using System.Collections;

public class WillRenderGameObject : MonoBehaviour 
{	
	private bool _bIsRender = false;
	private float _curTime = 0.0f;
	private float _lostTime = 0.0f;

	/// <summary>
	/// Gets a value indicating whether this instance is render.
	/// </summary>
	/// <value><c>true</c> if this instance is render; otherwise, <c>false</c>.</value>
	public bool IsRender
	{
		get{ return _bIsRender; }
	}

	/// <summary>
	/// Raises the will render object event.
	/// </summary>
	void OnWillRenderObject()
	{
		_curTime = Time.time;
	}
	
	private void _UpdataRenderTime()
	{
		_bIsRender = _curTime != _lostTime ? true : false;
		_lostTime = _curTime;

//		Debug.Log("_bIsRender: " + _bIsRender);
	}

	/// <summary>
	/// Start this instance.
	/// </summary>
	void Start () 
	{
	
	}


	/// <summary>
	/// Update this instance.
	/// </summary>
	void Update () 
	{
		_UpdataRenderTime();
	}
}
